package leetcode.code0500;

import java.util.ArrayList;
import java.util.List;

public class Solution extends Solution500 {

	static String[] lines = new String[] { "qwertyuiopQWERTYUIOP", "asdfghjklASDFGHJKL", "zxcvbnmZXCVBNM" };

	static int[] dic;

	static {
		dic = new int[128];
		for (int i = 0; i < lines.length; i++) {
			for (char c : lines[i].toCharArray()) {
				dic[c] = i;
			}
		}
	}

	@Override
	public String[] findWords(String[] words) {
		List<String> ans = new ArrayList<>();
		w: for (String str : words) {
			int index = dic[str.charAt(0)];
			for (char c : str.toCharArray()) {
				if (dic[c] != index) {
					continue w;
				}
			}
			ans.add(str);
		}
		return ans.toArray(new String[] {});
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();

	}

}
